<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算属性存在的问题</title>
</head>
<body>
<div id="app">

    <!--  无论是 familyName 还是 firstName变化都会引起  fullName 的更新  -->
    <!--  但是，发现了 fullName 发生变化，却不知道是哪个变化引起的  -->
    <div>
        姓氏：
        <input type="text" name="familyName" id="familyName" v-bind:value="familyName" v-on:input="onFamilyName">
    </div>

    <div>
        名字：
        <input type="text" name="firstName" id="firstName" v-bind:value="firstName" v-on:input="onFirstName">
    </div>

    <div>
        姓名：{{ fullName }}
    </div>
</div>
<script type="module">
    import {createApp, ref, reactive, computed} from "../../../../../js/vue.esm-browser.js";

    const app = createApp({
        setup() {

            let firstName = ref(null)
            let familyName = ref(null)

            function onFamilyName() {
                let family = document.getElementById("familyName")
                familyName.value = family.value
            }

            function onFirstName() {
                let first = document.getElementById("firstName")
                firstName.value = first.value
            }

            let fullName = computed(() => {
                return familyName.value + " " + firstName.value
            })
            return {
                firstName, familyName, onFamilyName, onFirstName, fullName,
            }
        }
    })

    app.mount("#app")
</script>
</body>
</html>